#define _CRT_SECURE_NO_WARNINGS
#define N 3
#include <stdio.h>
#include <string.h>

struct book
{
    double pride;
    char name[31];
};
void input(struct book b[], int n)
{
    int i;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        printf("Programming in ");
        scanf("%s", b[i].name);
        fgets()
        scanf("%lf",&b[i].pride);
        //printf("%s\n", b[i].name);
        //printf("%lf\n", b[i].pride);
    }
   /* for (i = 0; i < n; i++) {
        printf("%s\n", b[i].name);
        printf("%lf\n", b[i].pride);
    }*/
}
void sort(struct book b[], int n)
{
    int i, j;
    struct book temp;
    for (i = 0; i < n - 1; i++) {
        for (j = i + 1; j < n; j++) {
            if (b[i].pride > b[j].pride) {
                temp = b[i];
                b[i] = b[j];
                b[j] = temp;
            }
        }
    }
    for (i = 0; i < n; i++) {
        printf("%s\n", b[i].name);
        printf("%lf\n", b[i].pride);
    }
}
void output(struct book b[], int n)
{
    printf("%.2f,Programming in %s", b[n - 1].pride, b[n - 1].name);
    printf("\n");
    printf("%.2f,Programming in %s", b[0].pride, b[0].name);
}
int main()
{
    struct book n_b[N];
    input(n_b, N);
    sort(n_b, N);
    printf("\n");
    output(n_b, N);
    return 0;
}